/* ----------------------------------------------------------------------------------------------------------------------
 * WorldManager
 * -----------------------------------------------------------------------------------------------------------------------
 */

/* 
   
   1. 负责处理当前World，World提供地图与环境
   
   2. 
   
   3. 管理摄像机焦点
 */

/*
   <GameWorld>
            <Scenery  type = "image">                         Mountains  </Scenery>
			<Scenery  type = "tiled">                         Ground     </Scenery>
   
			
			<Entity   x = "??" y = "??" args = "??,??">  colonist_32_32  </Entity>
			<Entity   x = "??" y = "??" args = "??,??">  colonist_32_32  </Entity>
			<Entity   x = "??" y = "??" args = "??,??">  colonist_32_32  </Entity>
			<Entity   x = "??" y = "??" args = "??,??">  colonist_32_32  </Entity>
			
			<Entity   x = "??" y = "??" args = "??,??">  player          </Entity>
			
			<Entity   x = "??" y = "??" args = "??,??">  zombie          </Entity>
			<Entity   x = "??" y = "??" args = "??,??">  zombie          </Entity>
			<Entity   x = "??" y = "??" args = "??,??">  zombie          </Entity>
			<Entity   x = "??" y = "??" args = "??,??">  zombie          </Entity>
			<Entity   x = "??" y = "??" args = "??,??">  zombie          </Entity>
   </GameWorld>
 */ 
package pure.engine.world 
{
	import flash.events.EventDispatcher;
	import flash.geom.*;
	import pure.engine.system.IFrameObject;
	import pure.engine.system.ProcessManager;
	import pure.engine.entity.EntityManager;
	import pure.engine.entity.IEntity;
	import pure.engine.entity.Entity;
	import pure.engine.entity.Mirror;
	import pure.engine.events.EntityMouseEvent;
	import pure.engine.events.WorldContentEvent;
	import pure.utils.DesU;
	
	import pure.engine.system.ns_despair;

	use namespace ns_despair;
	
    /**
	 * @internal
	 * 
     * 世界管理器
	 * 
	 * @param ＃Pure
	 * 
     */
public class WorldManager
{


	ns_despair static var m_worldBodyList:Object;

	
	
	ns_despair static function registerWorldBody(worldBodyName:String, sortProperty:String):void
	{
		if (worldBodyName == null || worldBodyName == '')
		{
			throw new Error("[WorldManager] - ＃registerWorldBody - A world body does not have a null name.");
		}
		
		if (!m_worldBodyList)
		{
			m_worldBodyList = { };
		}
		
		else if (m_worldBodyList[worldBodyName])
		{
			throw new Error("[WorldManager] - ＃getWorldBody - world body ( "+worldBodyName+" ) has been registered.");
		}
		
		m_worldBodyList[worldBodyName] = new WorldBody(worldBodyName, sortProperty);
	}
	
	
	ns_despair static function getWorldBody(worldBodyName:String):WorldBody
	{
		if (!m_worldBodyList)
		{
			throw new Error("[WorldManager] - ＃getWorldBody - There has been no world body registered yet.");
		}

		if (!m_worldBodyList[worldBodyName])
		{
			throw new Error("[WorldManager] - ＃getWorldBody - The world body ( "+worldBodyName+" ) is not existed.");
		}
		
		return m_worldBodyList[worldBodyName];
	}

}
}